﻿using mozhi.smarterp.Finance.Enums;
using System;
using Volo.Abp;
using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.MultiTenancy;

namespace mozhi.smarterp.Finance.Banks
{
    public class BankAccountTransaction : AuditedAggregateRoot<Guid>, IMultiTenant
    {
        public Guid? TenantId {  get; private set; }

        public Guid BankAccountId { get; private set; }

        public BankTransactionType Type { get; private set; }

        public Guid DocumentId { get; private set; }

        public string DocumentNumber {  get; private set; }

        /// <summary>
        /// 交易日期
        /// </summary>
        public DateTime TransactionDate { get; private set; }

        /// <summary>
        /// 核销金额原币
        /// </summary>
        public decimal? AllocatedAmountFr { get; private set; }

        /// <summary>
        /// 核销金额本位币
        /// </summary>
        public decimal? AllocatedAmount {  get; private set; }

        private BankAccountTransaction() { }

        public BankAccountTransaction(Guid id, Guid bankAccountId, BankTransactionType type, Guid documentId, DateTime transactionDate , string documentNumber)
        {
            Id = id;
            BankAccountId = bankAccountId;
            Type = type;
            DocumentId = documentId;
            DocumentNumber = documentNumber;
            TransactionDate = transactionDate;

            Validate();
        }

        #region
        private void Validate()
        {
            Check.NotDefaultOrNull<Guid>(BankAccountId, nameof(BankAccountId));
            Check.NotDefaultOrNull<Guid>(DocumentId, nameof(DocumentId));
            Check.NotDefaultOrNull<DateTime>(TransactionDate, nameof(TransactionDate));
            Check.NotDefaultOrNull<BankTransactionType>(Type, nameof(Type));
            Check.NotNullOrEmpty(DocumentNumber, nameof(DocumentNumber));

        }
        #endregion
    }
}
